home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / intcase.com / INTCASE.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-07-27  |  1.6 KB  |  77 lines

  1. dseg    segment    word
  2.     assume ds:dseg
  3.  
  4.     extrn DosUpcase                 : dword
  5.         extrn LocaseTranslationtable : byte
  6.  
  7. dseg    ends
  8.  
  9. cseg    segment    word
  10.     assume cs:cseg
  11.  
  12.     locals @@
  13.  
  14. dummy   proc    far
  15. ; DosUpcase points to here under DOS < 3.0
  16.         public  dummy
  17.  
  18.         retf
  19. dummy   endp
  20.  
  21. ; function upcase ----------------------------
  22.  
  23. upcase    proc    far
  24.     public    upcase
  25.  
  26.         mov     bx,sp
  27.         mov     al,ss:[bx+4]   ; Get character into al
  28.  
  29.         cmp    al,97           ; 'a'
  30.     jb    @@1            ; If below, it can't be converted
  31.  
  32.     cmp    al,122           ; 'z'
  33.     jbe     @@2            ; If below, it's a standard lower case char
  34.  
  35.     call    [DosUpcase]    ; Let DOS do the conversion
  36.                                ; DOS ignores characters below #128
  37.  
  38.     jmp    short @@1
  39.  
  40. @@2:    sub    al,32          ; Convert to upper case
  41.  
  42. @@1:    retf    2              ; Remove parameter and return
  43.  
  44. upcase    endp
  45.  
  46. ; function locase ----------------------------
  47.  
  48. locase    proc    far
  49.     public    locase
  50.  
  51.         mov     bx,sp
  52.         mov     al,ss:[bx+4]   ; Get character into al
  53.  
  54.         cmp    al,65           ; 'A'
  55.     jb    @@1            ; If below, it can't be converted
  56.  
  57.     cmp    al,90           ; 'Z'
  58.     jbe    @@2            ; If below, it's a standard upper case char
  59.  
  60.         cmp     al,127         ; Is it in the extended char range ?
  61.     jbe    @@1            ; No, cannot convert
  62.  
  63.     sub    al,128         ; Yes, relocate for table [128..255]
  64.  
  65.     mov    bx,offset LocaseTranslationtable
  66.     xlat                   ; Actual convertion
  67.  
  68.     jmp    short @@1
  69.  
  70. @@2:    add    al,32          ; Convert to lower case
  71.  
  72. @@1:    retf    2              ; Remove parameter and return
  73.  
  74. locase    endp
  75.  
  76. cseg    ends
  77.  
  78.     end
  79.